function formhash(form, password) {
    // Create a new element input, this will be our hashed password field. 
    var p = document.createElement("input");
 
    // Add the new element to our form. 
    form.appendChild(p);
    p.name = "p";
    p.type = "hidden";
    p.value = hex_sha512(password.value);
 
    // Make sure the plaintext password doesn't get sent. 
    password.value = "";
 
    // Finally submit the form. 
    form.submit();
}
 
function change_pass(form, oldPassword, newPassword, newPasswordConfirm) {
     // Check each field has a value
    if (oldPassword.value == ''         || 
          newPassword.value == ''     || 
          newPasswordConfirm.value == '') {
 
        alert('Debe completar todos los datos. Intentelo nuevamente.');
        return false;
    }
    if (newPassword.value != newPasswordConfirm.value) {
        alert('La contraseña y la confirmacion no coinciden. Intentelo nuevamente.');
        return false;
    }
	if (oldPassword.value == newPassword.value) {
        alert('La contraseña anterior y la nueva deben ser distintas. Intentelo nuevamente.');
        return false;
    }

    // Password anterior
	var oldp = document.createElement("input");
    form.appendChild(oldp);
    oldp.name = "oldp";
    oldp.type = "hidden";
    oldp.value = hex_sha512(oldPassword.value);
 
    // Password nueva
	var newp = document.createElement("input");
    form.appendChild(newp);
    newp.name = "newp";
    newp.type = "hidden";
    newp.value = hex_sha512(newPassword.value);
 
    // Make sure the plaintext password doesn't get sent. 
    newPassword.value = "";
    newPasswordConfirm.value = "";
	oldPassword.value = "";
 
    // Finally submit the form. 
    form.submit();
    return true;
}